package com.hbmcc.rxjava.chapter01.holder

import android.view.View
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import androidx.viewpager.widget.ViewPager
import com.hbmcc.rxjava.R

/**
 * 创建日期：2020/11/11
 * 描述:所有的 ViewHolder 的集合
 * 作者:支豪亮
 */


/**
 * PagerView Banner
 */
class BannerViewHolder(item: View) : RecyclerView.ViewHolder(item) {
    val itemViewPager: ViewPager = item.findViewById(R.id.viewPager)

    init {
        itemViewPager.layoutParams.height =
            item.context.resources.displayMetrics.widthPixels * 313 / 500
    }
}


class PagerHolder(view: View) : RecyclerView.ViewHolder(view) {
    val viewPagerItem: ImageView = view.findViewById(R.id.viewPagerItem)
}


fun onProxyCreateViewHolder(view: View, viewType: Int): RecyclerView.ViewHolder {
    return when (viewType) {
        R.layout.view_pager -> BannerViewHolder(view)
        else -> PagerHolder(view)
    }
}